<template>
  <el-row :gutter="40" justify="space-between" class="panel-group">
    <el-col :xs="12" :sm="8" :lg="8" class="panel-card-col">
      <div class="panel-card">
        <div class="panel-card-icon-wrapper icon-people">
          <svg-icon icon-class="user" class="panel-card-icon" />
        </div>
        <div class="panel-card-description">
          <div class="panel-card-title">访客</div>
          <count-to :startVal="0" :endVal="visitorCount" :duration='3500' class="panel-card-num"></count-to>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="8" :lg="8" class="panel-card-col">
      <div class="panel-card">
        <div class="panel-card-icon-wrapper icon-message">
          <svg-icon icon-class="eye-open"  class="panel-card-icon" />
        </div>
        <div class="panel-card-description">
          <div class="panel-card-title">消息</div>
          <count-to :startVal="0" :endVal="visitorCount" :duration='3500' class="panel-card-num"></count-to>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="8" :lg="8" class="panel-card-col">
      <div class="panel-card">
        <div class="panel-card-icon-wrapper icon-system">
          <svg-icon icon-class="system"  class="panel-card-icon" />
        </div>
        <div class="panel-card-description">
          <div class="panel-card-title">系统</div>
          <count-to :startVal="0" :endVal="visitorCount" :duration='3500' class="panel-card-system"></count-to>
        </div>
      </div>
    </el-col>
  </el-row>
</template>

<script>
import { listPanelGroup } from '@/api/dashboard'
import countTo from 'vue-count-to'

export default {
  data() {
    return {
      visitorCount: 0
    }
  },
  mounted() {
    this.getPanelGroupData()
  },
  methods: {
    getPanelGroupData() {
      listPanelGroup().then(res => {
        this.visitorCount = res.data.visitorCount
      })
    }
  },
  components: {
    countTo
  }
}
</script>

<style lang="scss" scoped>
  .panel-group {
    margin-top: 20px;
    .panel-card-col {
      margin-bottom: 20px;
      .panel-card {
        height: 110px;
        display: flex;
        justify-content: space-between;
        background: #ffffff;
        box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
        padding: 0 15px;
        cursor: pointer;

        &:hover {
          .panel-card-icon-wrapper {
            color: #ffffff;
          }
          .icon-people {
            background: #40c9c6;
          }
          .icon-message {
            background: #36a3f7;;
          }
          .icon-system {
            background: #f4516c;;
          }
        }

        .panel-card-icon-wrapper {
          border-radius: 6px;
          margin: 15px 0;
          transition: all 0.38s ease-out;
          .panel-card-icon {
            margin: 15px;
            font-size: 50px;
          }
        }
        .icon-people {
          color: #40c9c6;
        }
        .icon-message {
          color: #36a3f7;;
        }
        .icon-system {
          color: #f4516c;;
        }

        .panel-card-description {
          display: flex;
          flex-direction: column;
          justify-content: space-around;
          font-weight: bold;

          .panel-card-title {
            line-height: 18px;
            font-size: 16px;
            color: rgba(0, 0, 0, 0.45);
          }
          .panel-card-num {
            font-size: 20px;
          }
        }
      }
    }

  }
</style>